package cn.le.messagePack;

import cn.le.bean.vo.NettyMsg;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToByteEncoder;
import org.msgpack.MessagePack;

public class MessagePackEncoder extends MessageToByteEncoder<NettyMsg> {

    @Override
    protected void encode(ChannelHandlerContext channelHandlerContext, NettyMsg msg, ByteBuf byteBuf) throws Exception {
        MessagePack pack = new MessagePack();
        byte[] data = pack.write(msg);
        byteBuf.writeBytes(data);
    }
}
